package Thread;
//线程的打断
public class Demo8 {
    private static boolean isQuit=false;
    public static void main(String[] args) {
        //boolean isQuit=false;
        Thread t=new Thread(()->{
            while (!isQuit){
                //
                System.out.println("线程工作中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程工作完毕");
        });
        t.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        isQuit=true;
        System.out.println("设置：isQuit 为 true");
    }
}
